package com.fancy.learncenter.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.fancy.learncenter.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.adapter.base.CustomViewHold;
import com.fancy.learncenter.bean.BaseDataBean;
import com.fancy.learncenter.bean.VitaDetailDataBean;
import com.fancy.learncenter.net.HttpMehtod;
import com.fancy.learncenter.net.IdeaObserver;
import com.superservice.lya.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by hyy on 2018/2/25.
 * Explain activity as
 */

public class WorkExperienceListAdapter extends CommonRecycleViewAdapter<VitaDetailDataBean.WorkListBean> {
    public WorkExperienceListAdapter(Activity mContext, ArrayList<VitaDetailDataBean.WorkListBean> itemDatas) {
        super(mContext, R.layout.activity_work_experience_list_item, itemDatas);
        this.myContext = mContext;
    }

    boolean isShow = true;

    private Activity myContext;

    public WorkExperienceListAdapter(Activity mContext, ArrayList<VitaDetailDataBean.WorkListBean> itemDatas, boolean isShow) {
        super(mContext, R.layout.activity_work_experience_list_item, itemDatas);
        this.isShow = isShow;
        this.myContext = mContext;
    }

    @Override
    public void bindView(CustomViewHold customViewHold, final VitaDetailDataBean.WorkListBean item, int position) {

        TextView time_tv = customViewHold.getView(R.id.time_tv);
        time_tv.setText(item.getTime_interval());

        TextView company_name = customViewHold.getView(R.id.company_name);
        company_name.setText(item.getCompany_name());

        TextView work_name = customViewHold.getView(R.id.work_name);
        work_name.setText(item.getPostion());


        TextView edit_tv = customViewHold.getView(R.id.edit_tv);
        TextView delete_tv = customViewHold.getView(R.id.delete_tv);

        if (!isShow) {
            edit_tv.setVisibility(View.GONE);
            delete_tv.setVisibility(View.GONE);
        }
        delete_tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickCallBack.deleCallBack(item);
            }
        });
        edit_tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickCallBack.editCallBack(item);
            }
        });


    }


    private OnClickCallBack onClickCallBack;

    public OnClickCallBack getOnClickCallBack() {
        return onClickCallBack;
    }

    public void setOnClickCallBack(OnClickCallBack onClickCallBack) {
        this.onClickCallBack = onClickCallBack;
    }

    public interface OnClickCallBack {
        abstract void deleCallBack(VitaDetailDataBean.WorkListBean item);

        abstract void editCallBack(VitaDetailDataBean.WorkListBean item);
    }
}
